﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PhoneBilling.Models;

namespace PhoneBilling.Controllers
{
    public class SharedController : Controller
    {
        //
        // GET: /Shared/

        public ActionResult Error()
        {
            string message = TempData["Error"] as string;
            if (message == null)
                message = "未知错误！";

            TempData["Error"] = null;
            return View(new MessageModel() { Message = message});
        }

        public ActionResult ErrorOnly()
        {
            string message = TempData["Error"] as string;
            if (message == null)
                message = "未知错误！";

            TempData["Error"] = null;
            return View(new MessageModel() { Message = message });
        }

        public ActionResult Message()
        {
            string message = TempData["Message"] as string;
            if (message == null)
                message = "操作成功！";

            TempData["Message"] = null;
            return View(new MessageModel() { Message = message });
        }

        public ActionResult MessageOnly()
        {
            string message = TempData["Message"] as string;
            if (message == null)
                message = "操作成功！";

            TempData["Message"] = null;
            return View(new MessageModel() { Message = message });
        }
        public ActionResult Print()
        {
            if(!TempData.ContainsKey("PrintContent"))
                return this.RedirectToAction("../Shared/Error", new { message = "没有可以打印的内容" });
            string content = TempData["PrintContent"].ToString();

            return View(new PrintModel() { Content = content});
        }
    }
}
